package com.teach;

/**
 * <pre>
 * - 多catch
 * Author : J.L.Zhou
 * E-Mail : 2233875735@qq.com
 * Tel : 151 1104 7708
 * Date : 2021-04-09 14:33
 * Version : 1.0
 * Copyright 2021 jlzhou.top Inc. All rights reserved.
 * Warning: this content is only for internal circulation of the company.
 *          It is forbidden to divulge it or use it for other commercial purposes.
 * </pre>
 **/
public class Demo08 {

  public static void main(String[] args) {
    try{
      int x=100;
      int y=0;
      String s=null;
      System.out.println("x/y="+x/y);//ArithmeticException
      System.out.println("x/y计算结束");
      System.out.println("字符串长度"+s.length());//NullPointerException
    }catch(NullPointerException e){
      System.out.println("发生了空指针异常");
    }catch(ArithmeticException e){
      System.out.println("发生了数学异常，注意除数不能为0.");
    }catch(Exception e){
      System.out.println("发生了其他异常");
    }finally {
      //最多一个
    }
    System.out.println("main方法运行结束");
  }
}
